package com.mall.controller;

import com.mall.domain.Menus;
import com.mall.service.IMenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 菜单web层
 * @author : Bei-Zhen
 * @date : 2020-12-26 11:51
 */
@Controller
public class MenusController {

    @Autowired
    private IMenusService menusService;

    /**
     * 渲染树形菜单
     * @param
     * @return
     */
    @RequestMapping("/menus")
    public  @ResponseBody
    Map<String,Object> getMenus() {
        Map<String,Object> menusMap = new HashMap<>();
        //获取菜单集合
        List<Menus> menus = menusService.getTree();
        //放入Map集合
        menusMap.put("data",menus);

        //创建状态Map
        Map<String,Object> metaMap = new HashMap<>();
        metaMap.put("msg","获取菜单列表成功");
        metaMap.put("status",200);

        menusMap.put("meta",metaMap);
        return menusMap;
    }
}
